<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{:session('cp.cpsysname')}--商户管理平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="{:config('webconfig.description');}">
    <meta name="keywords" content="{:config('webconfig.keywords');}">
    <meta name="author" content="runoob">
    <link rel="stylesheet" href="__STATIC_URL__/static/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/index.css"/>
    <script src="__STATIC_URL__/static/js/jquery-2.1.4.min.js"></script>
    <script src="__STATIC_URL__/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="__STATIC_URL__/static/js/commen.js" type="text/javascript" charset="utf-8"></script>
    <style>
        thead tr th{
            text-align: center;
        }
        tbody tr td{
            text-align: center;
        }
        .modal-body .nav>li>a {
            position: relative;
            display: block;
            padding: 3px 15px;
            background: #d8d8d8;
        }
        .modal-body .nav>li>a:hover{
            background: #d8d8d8;
        }
        .modal-body  .nav> li.active > a::before {
            width: 0;
            height: 0;
            border-left: 8px solid transparent;
            border-right: 8px solid transparent;
            border-top: 8px solid #d8d8d8;
            content: " ";
            position: absolute;
            right: 50%;
            bottom: -8px;
            margin-right: -8px;
            z-index: 2;
        }
        .info-row{
            line-height: 32px;
            color: #333;
        }
        .info-row label{
            padding-left: 15px;
            padding-right: 15px;
        }
        .r-title{
            color: #333;
        }
    </style>
    <style>
        .form-self{
            display: block;
            width: 100%;
            padding: 6px 12px;
            font-size: 14px;
            color: #555;
            background-color: #fff;
            background-image: none;
            border: 1px solid #ccc;
            border-radius: 4px;
            -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
            box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
            -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
            -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
            transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
        }
    </style>
</head>
<body>
{include file='public/header'/}
<!------------------导航-------------------------->
<section id="content">
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content" >
        <div class="page-heading mgl15 mgr15">
            <!--路径导航-->
            <ol class="breadcrumb">
                <li>当前位置是:</li>
                <li>
                    <a href="javascript:;">会员卡管理</a>
                </li>
                <li>
                    <a href="{:url('cardus/carduslist')}">会员卡列表</a>
                </li>
                <li>
                    <a href="{:url('cardus/cardinfo',['card_id'=>$card['card_id']])}">控制面板</a>
                </li>
                <li class="active">会员</li>
            </ol>

        </div>
        <div class="panel panel-default panel-search mgl15 mgr15">
            <div class="panel-heading">
                <h5 class="panel-title"><span class="glyphicon glyphicon-search pull-left" style="margin-right: 10px;"></span>会员查找</h5>
            </div>
            <div class="panel-body">
                <form action="" method="get" class="form-horizontal table-search form-search" role="form" id="machform">
                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">昵称：</label>
                            <div class="col-sm-9">
                                <input type="text"  autocomplete="off" disableautocomplete class="form-control"  placeholder="请输入" value="{$p_data['nickname']}" name="nickname">
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">卡号：</label>
                            <div class="col-sm-9">
                                <input type="text" autocomplete="off" disableautocomplete class="form-control"  placeholder="请输入卡号" value="{$p_data['code']}" name="code">
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">激活状态：</label>
                            <div class="col-sm-9">
                                <select name="fire" class="form-control">
                                    <option value="">请选择激活状态</option>
                                    <option value="1" {if condition="$p_data['fire'] eq '1'"}selected{/if}>已激活</option>
                                    <option value="0" {if condition="$p_data['fire'] eq '0'"}selected{/if}>未激活</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">积分筛选：</label>
                            <div class="col-sm-9">
                                <select name="bonus_scr" class="form-control">
                                    <option value="">请选择排序</option>
                                    <option value="1" {if condition="$p_data['bonus_scr'] eq '1'"}selected{/if}>从高到低</option>
                                    <option value="2" {if condition="$p_data['bonus_scr'] eq '2'"}selected{/if}>从低到高</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">余额筛选：</label>
                            <div class="col-sm-9">
                                <select name="balance_scr" class="form-control">
                                    <option value="">请选择排序</option>
                                    <option value="1" {if condition="$p_data['balance_scr'] eq '1'"}selected{/if}>从高到低</option>
                                    <option value="2" {if condition="$p_data['balance_scr'] eq '2'"}selected{/if}>从低到高</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">领取时间筛选：</label>
                            <div class="col-sm-9">
                                <select name="get_scr" class="form-control">
                                    <option value="">请选择排序</option>
                                    <option value="1" {if condition="$p_data['get_scr'] eq '1'"}selected{/if}>从早到晚</option>
                                    <option value="2" {if condition="$p_data['get_scr'] eq '2'"}selected{/if}>从晚到早</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="panel-footer">
                <a href="javascript:;" class="btn btn-primary" onclick="searchform()">查找</a>
                <a href="javascript:;" class="btn btn-default" onclick="clearform()">清空</a>
            </div>
        </div>
        <div class="panel mgl15 mgr15" >

            <div class="panel-heading addCharts" style="background:#ededed;">
                会员列表
                {if condition='$card["type"] eq "0"'}
                <a href="{:url('cardus/getlist',['card_id'=>$card['card_id'],'type'=>1])}" class="btn btn-default pull-right mgl15" style="margin-top: -6px;">当前会员</a>
                <a href="{:url('cardus/getlist',['card_id'=>$card['card_id'],'type'=>0])}" class="btn btn-success pull-right" style="margin-top: -6px;">查看已删除会员</a>
                {else/}
                <a href="{:url('cardus/getlist',['card_id'=>$card['card_id'],'type'=>1])}" class="btn btn-success pull-right mgl15" style="margin-top: -6px;">当前会员</a>
                <a href="{:url('cardus/getlist',['card_id'=>$card['card_id'],'type'=>0])}" class="btn btn-default pull-right" style="margin-top: -6px;">查看已删除会员</a>
                {/if}
            </div>
            <div class="panel-body">
                <table class="table table-bordered" data-toolbar="#toolbar">
                    <thead>
                    <tr>
                        <th>会员卡号</th>
                        <th>状态</th>
                        <th>昵称</th>
                        <th>手机号</th>
                        <th>领取时间</th>
                        <th>积分</th>
                        <th>余额</th>
                        <th>使用频次</th>
                        {if condition="checkPath('cardus/getcardupdate') || checkPath('report/cardusbalance')"}
                        <th>操作</th>
                        {/if}
                    </tr>
                    </thead>
                    <tbody>
                    {volist name="list" id="vo"}
                    <tr>
                        <td><a class="btn-link" data-toggle="modal" {if condition="checkPath('cardus/cardInfo')"} data-target="#myModal" {/if} data-id="{$vo.id}">{$vo.code}</a></td>
                        <td>
                            {switch name="vo.fire"}
                            {case value="1"}已激活{/case}
                            {case value="0"}未激活{/case}
                            {/switch}
                        </td>
                        <td>
                            {eq name="vo.fire" value="1"}
                            {$vo.nickname}
                            {else/}
                            未获取
                            {/eq}
                        </td>
                        <td>{$vo.phone}</td>
                        <td>{$vo.create_time}</td>
                        <td>{$vo.bonus}</td>
                        <td>{$vo.balance}</td>
                        <td>{:get_cardus_frequency($vo['openid'])}/次</td>
                        {if condition="checkPath('cardus/getcardupdate') || checkPath('report/cardusbalance')"}
                        <td class="chakan">
                            {if condition="checkPath('cardus/getcardupdate')"}
                            <a class="btn-link" data-toggle="modal" data-target="#czModal" data-id="{$vo.id}" data-type="1">充值</a>
                            {/if}
                            {if condition="checkPath('cardus/getcardupdate')"}
                            <a class="btn-link" data-toggle="modal" data-target="#hexiaoModal" data-id="{$vo.id}" data-type="2">核销</a>
                            {/if}
                            {if condition="checkPath('report/cardusbalance')"}
                            <a class="btn-link" href="{:url('report/cardusbalance',['get_id'=>$vo['id']])}">消费明细</a>
                            {/if}
                            {if condition="checkPath('cardus/edituserinfo')"}
                            <a class="btn-link" href="{:url('cardus/edituserinfo',['id'=>$vo['id']])}">修改</a>
                            {/if}
                        </td>
                        {/if}
                    </tr>
                    {/volist}
                    </tbody>
                </table>
                {$list->render()}
            </div>
        </div>
        {include file='public/footer'/}
    </div>
</section>
<!-- 充值Modal -->
<div class="modal fade" id="czModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="czModalLabel">会员卡充值</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="cz">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">门店：</label>
                        <div class="col-sm-10">
                            <input type="hidden" name="id" id="czcard-id" >
                            <select name="mid" id="czhe-md" class="form-control" required="required">
                                <option value="">选择门店</option>
                                {volist  name="mach" id="md"}
                                <option value="{$md.id}">{$md.merchant}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">核销员：</label>
                        <div class="col-sm-10">
                            <input type="text" name="username" id="cznickname" readonly="readonly"  required="required" class="form-control" value="{$user.nickname}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">充值类别：</label>
                        <div class="col-sm-10">
                            <select id="cz-kind" class="form-control" required="required" onchange="czkindfun(this.value)">
                                <option value="1">余额</option>
                                <option value="2">积分</option>
                            </select>
                        </div>
                    </div>
                    <div id="czshow">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">充值面额：</label>
                            <div class="col-sm-10">
                                <select name="giveid" id="czme" class="form-control">
                                    <option value="">其他金额</option>
                                    {volist  name="czgive" id="me"}
                                    <option value="{$me.id}" data-money="{$me.zs_money}{if condition='$me.zs_money' neq ''}元{/if}" data-zs="{:getgivecard($me.zs_card_id,0)}">充值{$me.cz_money}元</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>
                        <div class="form-group hidden" id="czsm-wrap">
                            <label class="col-sm-2 control-label">赠送：</label>
                            <div class="col-sm-10">
                                <div class="form-self" id="czsm"></div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group" id="czje">
                        <label class="col-sm-2 control-label" id="czname">充值金额：</label>
                        <div class="col-sm-10">
                            <input type="hidden" name="type" id="czmodal-type">
                            <input type="text" name="add_balance" id="czadd_balance" oninput="if(isNaN(value))execCommand('undo')"  required="required" class="form-control" value="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">充值说明：</label>
                        <div class="col-sm-10">
                            <textarea name="record_balance" id="czrecord_balance" rows="3" style="resize: none;" required="required" class="form-control">后台充值</textarea>
                            <div class="r-desc">请对本次余额操作进行说明</div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="czsure">确认</button>
            </div>
        </div>
    </div>
</div>

<!-- 核销Modal -->
<div class="modal fade" id="hexiaoModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="hexiaoModalLabel">会员卡核销</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="hexiao">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">门店：</label>
                        <div class="col-sm-10">
                            <input type="hidden" name="id" id="card-id" >
                            <select name="mid" id="he-md" class="form-control" required="required">
                                <option value="">选择门店</option>
                                {volist  name="mach" id="md"}
                                <option value="{$md.id}">{$md.merchant}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">核销类型：</label>
                        <div class="col-sm-10">
                            <select id="he-type" class="form-control" required="required" onchange="changetype(this.value)">
                                <option value="1">金额</option>
                                <option value="2">积分</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">核销员：</label>
                        <div class="col-sm-10">
                            <input type="text" name="username" id="nickname" readonly="readonly"  required="required" class="form-control" value="{$user.nickname}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" id="he-name">核销金额：</label>
                        <div class="col-sm-10">
                            <input type="hidden" name="type" id="modal-type">
                            <input type="text" name="add_balance" id="add_balance" oninput="if(isNaN(value))execCommand('undo')"  required="required" class="form-control" value="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">核销说明：</label>
                        <div class="col-sm-10">
                            <textarea name="record_balance" id="record_balance" rows="3" style="resize: none;" required="required" class="form-control">后台核销</textarea>
                            <div class="r-desc">请对本次余额操作进行说明</div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="hxsure">确认</button>
            </div>
        </div>
    </div>
</div>
<!-- 会员资料Modal -->
<div class="modal fade bs-example-modal-sm" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog modal-sm" role="document" style="width: 798px;height: 320px;">
        <div class="modal-content" style="height: 100%;">
            <div class="modal-body">
                <div id="info_nickname">
                    <span style="font-size: 22px;" id="nick-name"></span>
                </div>
                <!-- Tab panes -->
                <div class="tab-content">
                    <div role="tabpanel" class="tab-pane active" id="home">
                        <div class="r-title" style="line-height: 42px;font-size: 18px;font-weight: 700;border-bottom: 1px solid #ddd;margin-top: 12px;margin-bottom: 12px;">
                            会员资料
                        </div>
                        <div class="row info-row" id="templateHtml">
                            <script id="modallist" type="text/html">
                                <div class="col-xs-6">
                                    <label class="col-xs-4 text-right ng-binding">昵称：</label>
                                    <div class="col-xs-8 ng-binding">{{list.nickname}}</div>
                                </div>
                                <div class="col-xs-6">
                                    <label class="col-xs-4 text-right">会员卡号：</label>
                                    <div class="col-xs-8">{{list.code}}</div>
                                </div>
                                <div class="col-xs-6">
                                    <label class="col-xs-4 text-right ng-binding">积分：</label>
                                    <div class="col-xs-8 ng-binding">{{list.bonus}}</div>
                                </div>
                                <div class="col-xs-6">
                                    <label class="col-xs-4 text-right ng-binding">余额：</label>
                                    <div class="col-xs-8">{{list.balance}}</div>
                                </div>
                                {eq name=":getfirefield($card['card_id'],'USER_FORM_INFO_FLAG_MOBILE')" value="1"}
                                <div class="col-xs-6">
                                    <label class="col-xs-4 text-right ng-binding">手机号：</label>
                                    <div class="col-xs-8">{{list.phone}}</div>
                                </div>
                                {/eq}
                                {eq name=":getfirefield($card['card_id'],'USER_FORM_INFO_FLAG_SEX')" value="1"}
                                <div class="col-xs-6">
                                    <label class="col-xs-4 text-right ng-binding">性别：</label>
                                    {{ if list.sex == '1'}}
                                    <div class="col-xs-8">男</div>
                                    {{/if}}
                                    {{ if list.sex == '0' }}
                                    <div class="col-xs-8">女</div>
                                    {{/if}}
                                </div>
                                {/eq}
                                {eq name=":getfirefield($card['card_id'],'USER_FORM_INFO_FLAG_NAME')" value="1"}
                                <div class="col-xs-6">
                                    <label class="col-xs-4 text-right ng-binding">姓名：</label>
                                    <div class="col-xs-8">{{list.name}}</div>
                                </div>
                                {/eq}
                                {eq name=":getfirefield($card['card_id'],'USER_FORM_INFO_FLAG_LOCATION')" value="1"}
                                <div class="col-xs-6 ng-scope">
                                    <label class="col-xs-4 text-right ng-binding">地址：</label>
                                    <div class="col-xs-8">{{list.address}}</div>
                                </div>
                                {/eq}
                                {eq name=":getfirefield($card['card_id'],'USER_FORM_INFO_FLAG_BIRTHDAY')" value="1"}
                                <div class="col-xs-6">
                                    <label class="col-xs-4 text-right ng-binding">生日：</label>
                                    <div class="col-xs-8">{{list.birthday}}</div>
                                </div>
                                {/eq}
                                {eq name=":getfirefield($card['card_id'],'USER_FORM_INFO_FLAG_IDCARD')" value="1"}
                                <div class="col-xs-6">
                                    <label class="col-xs-4 text-right ng-binding">身份证：</label>
                                    <div class="col-xs-8">{{list.idnumber}}</div>
                                </div>
                                {/eq}
                                {eq name=":getfirefield($card['card_id'],'USER_FORM_INFO_FLAG_EMAIL')" value="1"}
                                <div class="col-xs-6">
                                    <label class="col-xs-4 text-right ng-binding">邮箱：</label>
                                    <div class="col-xs-8">{{list.email}}</div>
                                </div>
                                {/eq}
                                {eq name=":getfirefield($card['card_id'],'USER_FORM_INFO_FLAG_INDUSTRY')" value="1"}
                                <div class="col-xs-6">
                                    <label class="col-xs-4 text-right ng-binding">行业：</label>
                                    <div class="col-xs-8">{{list.industry}}</div>
                                </div>
                                {/eq}
                                {eq name=":getfirefield($card['card_id'],'USER_FORM_INFO_FLAG_INCOME')" value="1"}
                                <div class="col-xs-6">
                                    <label class="col-xs-4 text-right ng-binding">收入：</label>
                                    <div class="col-xs-8">{{list.income}}</div>
                                </div>
                                {/eq}
                                {eq name=":getfirefield($card['card_id'],'USER_FORM_INFO_FLAG_HABIT')" value="1"}
                                <div class="col-xs-6">
                                    <label class="col-xs-4 text-right ng-binding">兴趣爱好：</label>
                                    <div class="col-xs-8">{{list.habit}}</div>
                                </div>
                                {/eq}
                                {eq name=":getfirefield($card['card_id'],'USER_FORM_INFO_FLAG_EDUCATION_BACKGRO')" value="1"}
                                <div class="col-xs-6">
                                    <label class="col-xs-4 text-right ng-binding">教育背景：</label>
                                    <div class="col-xs-8">{{list.backgro}}</div>
                                </div>
                                {/eq}
                                {eq name=":getfirefield($card['card_id'],'实体卡号')" value="1"}
                                <div class="col-xs-6">
                                    <label class="col-xs-4 text-right ng-binding">实体卡号：</label>
                                    <div class="col-xs-8">{{list.old_code}}</div>
                                </div>
                                {/eq}
                            </script>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="__STATIC_URL__/static/js/template.js"></script>
<script src="__STATIC_URL__/static/layer/layer.js"></script>
<script>
    var czhtml = $("#czshow").html();
    function czkindfun(value){
        if(value=='1'){
            $("#czname").text("充值金额：");
            $("#czje").removeClass("hidden");
            $("#czshow").html(czhtml);
            $("#czadd_balance").attr("name","add_balance");
        }else if(value="2"){
            $("#czadd_balance").attr("name","add_bonus");
            $("#czshow").html('');
            $("#czname").text("充值积分：");
            $("#czje").removeClass("hidden");
        }
    }
    function changetype(value){
        if(value=='1'){
            $("#he-name").text("核销金额：");
            $("#add_balance").attr("name","add_balance");
            $("#record_balance").attr("name","record_balance");
        }else if(value="2"){
            $("#he-name").text("核销积分：");
            $("#add_balance").attr("name","bonus");
            $("#record_balance").attr("name","record_bonus");
        }
    }
    function getDatas(val){
        var url= "{:url('pay/requestname')}";
        $.ajax({
            url:url,
            type:"post",
            data:{
                merchant:val
            },
            success:function(data){
                if(data!=""){
                    var list = "";
                    for(var i=0;i<data.length;i++){
                        list+="<li>"+data[i].merchant+"</li>";
                    }
                    $(".searchlist ul").html(list);
                    $(".searchlist").removeClass("hide");
                }else{
                    $(".searchlist ul").html('');
                    $(".searchlist").addClass("hide");
                }
            }
        })
    }
    function hexiao(url,id,btn){
        $("#"+btn).attr("disabled","disabled");
        $.ajax({
            url:url,
            type:"post",
            data:$("#"+id).serialize(),
            success:function(data){
                console.log(data)
                if(data.code==0){
                    layer.msg(data.message,{icon:1,time:1000});
                    setTimeout("window.location.reload()",1000)
                    return false;
                }else{
                    $("#"+btn).removeAttr("disabled");
                    layer.alert(data.message,{icon:7});
                    return false;
                }
            }
        })
    }
    $(function(){
        //        获取充值说明
        $("#cz").on('change','#czme',function(){
            console.log('asdf');
            var val = $(this).val();
            var zs = $(this).find("option:selected").attr("data-zs");
            var money = $(this).find("option:selected").attr("data-money");
            var html = "";
            if(val){
                $("#czsm-wrap").removeClass("hidden");
                $("#czje").addClass("hidden");
            }else{
                $("#czsm-wrap").addClass("hidden");
                $("#czje").removeClass("hidden");
            }
            if(money){
                money="赠送金额："+money+"<br/>"
            }
            if(zs){
                zs = "赠送优惠券："+zs
            }
            $("#czsm").html(money+zs);
        });
        $("#czModal").on('show.bs.modal',function () {
            var id = $(event.target).attr("data-id");
            $("#czcard-id").val(id);
        });
//        核销方法
        $("#hexiaoModal").on('show.bs.modal',function () {
            var id = $(event.target).attr("data-id");
            var type = $(event.target).attr("data-type");
            $("#card-id").val(id);
            $("#modal-type").val(type);
            if(type==1){
                $("#hexiaoModalLabel").text("会员卡充值");
            }else if(type==2){
                $("#hexiaoModalLabel").text("会员卡核销");
            }
        });
        $("#hexiaoModal").on('hide.bs.modal',function () {
            $("#card-id").val("");
            $("#he-md").val("");
            $("#record_bonus ").val("");
            $("#add_bonus ").val("");
        });
        $("#czsure").click(function(){
            var mid = $("#czhe-md").val();
            var user = $("#cznickname").val();
            var kind = $("#cz-kind").val();
            if(mid==""){
                layer.alert("请选择门店",{icon:7});
                return false;
            }
            if(nickname==""){
                layer.alert("核销员不能为空",{icon:7});
                return false;
            }
            if(kind=='1'){
                hexiao("{:url('cardus/getrecharge')}","cz",'czsure')
            }else if(kind=='2'){
                hexiao("{:url('cardus/inc_bonus')}","cz",'czsure')
            }else{
                layer.alert("请选择充值类型！",{icon:7});
                return false;
            }

        })
        $("#hxsure").click(function(){
            var mid = $("#he-md").val();
            var user = $("#nickname").val();
            var type = $("#modal-type").val();
            var kind = $("#he-type").val();
            if(type==""){
                layer.alert("请重新选择操作",{icon:7});
                return false;
            }
            if(mid==""){
                layer.alert("请选择门店",{icon:7});
                return false;
            }
            if(nickname==""){
                layer.alert("核销员不能为空",{icon:7});
                return false;
            }
            if(kind=='1'){
                hexiao("{:url('cardus/getcardupdate')}","hexiao",'hxsure');
            }else if(kind=='2'){
                hexiao("{:url('cardus/hx_bonus')}","hexiao",'hxsure');
            }
//            hexiao("{:url('cardus/getcardupdate')}","hexiao")
//
        })
//        会员卡资料
        $("#myModal").on("show.bs.modal",function(){
            var id = $(event.target).data("id");
            var datas = {};
            $.ajax({
                url:"{:url('cardus/getcardinfo')}",
                type:"post",
                data:{
                    id:id
                },
                success:function(data){
                    $("#nick-name").text(data.nickname);
                    datas.list = data;
                    var html = template('modallist', datas);
                    $("#templateHtml").html(html);
                }
            })
        })
    })
</script>
</body>


</html>
